package com.ls.controller;


import com.ls.model.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
@RequestMapping("portal")
public class PortalController {

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/depts")
    public List<Department> portals() {
        ResponseEntity<List> entity = restTemplate.getForEntity("http://localhost:9090/service/depts", List.class);
        System.out.println("portal被访问了");
        return entity.getBody();
    }

}
